#include <stdio.h>
#include <stdlib.h>
#include <assert.h>

#include "ll.h"

void test_pushpop() {
	ll_list* list = ll_create();
	char* s;
	int i, j;

	char *strings[] = {"a", "b", "c", "d"};

	for (i = 0; i < 4; i++) {
		ll_push(list, strings[i]);
	}

	j = 3;
	while (s = ll_pop(list)) {
		assert(strcmp(s, strings[j]) == 0);
		j--;
	}

	ll_delete(list);
}

void test_getset() {
	ll_list* list = ll_create();
	char *strings[] = {"a", "b", "c", "d"};
	int i;

	for (i = 0; i < 4; i++) {
		ll_push(list, strings[i]);
	}

	for (i = 0; i < 4; i++) {
		char *s = ll_get(list, i);
		assert(strcmp(s, strings[i]) == 0);
	}

	ll_delete(list);
}

int main(int argc, char **argv) {
	test_pushpop(); printf("OK test push pop\n");
	test_getset(); printf("OK test get set\n");
}
